from PyQt4 import QtCore, QtGui

import BrowerWindow
import OutputWindow
import GerneralWindow

import VCore


class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()

        self.mdiArea = QtGui.QMdiArea()
        self.mdiArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.mdiArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
        self.setCentralWidget(self.mdiArea)

        self.__CreateAction()
        self.__CreateOutputer()
        self.__CreateBrower()   
        self.__CreateMenus()
        self.__CreateToolBars()
        self.__CreateStatusBar()
        
        self.setWindowTitle("Normtrom")
        
    
    def __CreateAction(self):
        self.gerneral_action = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&Gernel",
        self, shortcut=QtGui.QKeySequence.New,
        statusTip="Gerneral", triggered=self.__Gernel)
        
    def __CreateOutputer(self):
        self.output_dockwidget = QtGui.QDockWidget("OutPut")
        self.output_window = OutputWindow.OutputWindow()
        self.output_dockwidget.setWidget(self.output_window)
        self.addDockWidget(QtCore.Qt.BottomDockWidgetArea or QtCore.Qt.RightDockWidgetArea,  self.output_dockwidget)
        
    def __CreateBrower(self):
        self.brower_dockwidget= QtGui.QDockWidget("Files")
        self.brower_window = BrowerWindow.BrowerWindow()
        self.brower_dockwidget.setWidget(self.brower_window)
        self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self.brower_dockwidget)

    def __CreateMenus(self):
        self.file_menu = self.menuBar().addMenu("&File")
        self.file_menu.addAction(self.gerneral_action)
        
    def __CreateToolBars(self):
        self.toolbar = self.addToolBar("ToolBar")
        self.toolbar.addAction(self.gerneral_action)
        
    def __CreateStatusBar(self):
        self.statusBar().showMessage("Ready")
        
    def closeEvent(self, event):
        self.mdiArea.closeAllSubWindows()
        event.accept()

    def about(self):
        QtGui.QMessageBox.about(self, "About Nortrom.")


    def __Gernel(self):
        child = self.mdiArea.addSubWindow(GerneralWindow.GerneralWindow())
        child.show()
        child.showMaximized()

if __name__ == '__main__':

    import sys
    
    app = QtGui.QApplication(sys.argv)
    mainWin = MainWindow()
    mainWin.show()
    sys.exit(app.exec_())
